package com.ibm.iisp.cloud.test.consumer.web;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import com.ibm.iisp.cloud.test.service.TestGroup;
import com.ibm.iisp.cloud.test.service.TestGroupService;
import com.ibm.iisp.cloud.test.service.TestItem;

/**
 * Web MVC层 示例Rest
 * 
 * @author johnny
 *
 */
@RestController
public class ConsumerResource {

	@Autowired
	TestGroupService baseService;

	@GetMapping(value = "/test/testgroups/sample")
	List<TestGroup> searchBySample() {
		TestGroup group = new TestGroup();
		group.setName("Test group1.");
		ArrayList<TestItem> items = new ArrayList<>();
		group.setItems(items);
		TestItem item = new TestItem();
		item.setItemCode("Item1");
		items.add(item);
		item = new TestItem();
		item.setItemCode("Item2");
		items.add(item);
		return baseService.searchBySample(group);
	}

}